package com.jg.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.jg.comm.responce.PageResult;
import com.jg.model.dto.CategoriesQuery;
import com.jg.model.entity.Categories;
import com.jg.mapper.CategoriesMapper;
import com.jg.service.CategoriesService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Service;

import javax.xml.transform.Result;

/**
 * <p>
 * 类别表 服务实现类
 * </p>
 *
 * @author 86130
 * @since 2025-09-19 11:21
 */
@Service
public class CategoriesServiceImpl extends ServiceImpl<CategoriesMapper, Categories> implements CategoriesService {

    @Override
    public PageResult<Categories> getCategoryPage(CategoriesQuery categoriesQuery) {
        Page<Categories> page = new Page<>(categoriesQuery.getPageNum(), categoriesQuery.getPageSize());
        LambdaQueryWrapper<Categories> queryWrapper = new LambdaQueryWrapper<>();
        queryWrapper.like(StringUtils.isNotBlank(categoriesQuery.getCategoryName()),Categories::getCategoryName,categoriesQuery.getCategoryName());
        return PageResult.of(this.page(page,queryWrapper));
    }
}
